#include <windows.h>
#include <windowsx.h>
BOOL CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
int ed[3];
/*1 Creiamo il DC (display) dove disegnare*/
HDC hdc = CreateDC(TEXT("DISPLAY"),NULL,NULL,NULL);
/*2 creiamo un pennello e gli diamo come colore iniziale NERO*/
HBRUSH hbr = CreateSolidBrush(RGB(0,0,0));
/*3 creiamo la classe rettangolo*/
RECT Rect;
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil){
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
/*Disegniamo la finestra di dialogo*/
DialogBoxParam(0,"Dlg",0,WindowProcedure,0);
/*4 Impostiamo le coordinate del rettangolo*/
Rect.left = 5;
Rect.top = 5;
Rect.bottom = 500;
Rect.right = 176;
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0)){
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
/* This function is called by the Windows function DispatchMessage() */
BOOL CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
switch (message) { /* handle the messages */
case WM_CLOSE:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
case WM_COMMAND:
if (HIWORD(wParam)==BN_CLICKED&&LOWORD(wParam)==1000){
/*5 Disegno vero e proprio: col pennello 'hbr' coloriamo il
rettangolo 'Rect' contenuto nel display 'hdc'*/
FillRect(hdc,&Rect,hbr);
}
break;
}
return 0;
}